<?php
// -----------------------------------------------------------------------------

include "../config/config.php";
include "../auth.php";
include "../DBManager.php";

// -----------------------------------------------------------------------------

if (!isset($_GET["id"])) {
    exit("需要传入有效的参数！");
}

$id = $_GET["id"];

// -----------------------------------------------------------------------------
// 数据库相关设置
// -----------------------------------------------------------------------------

$dbPath = "../" . $dbPath; // 不加这行语句的话会报错，提示找不到对应路径
$db = new DBManager("sqlite:" . $dbPath);

// -----------------------------------------------------------------------------

if ($db->shoppingListExist($id)) {
    $db->deleteShoppingListById($id);
    if ($db->purchasedExist($id)) {
        $db->deletePurchasedById($id);
    }
    echo "删除成功！";
} else {
    echo "要删除的购物清单不存在";
}
